﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;

namespace IHISCETeim.Web.MachineSys.FTradeModel
{
    public partial class FTradeAgeDetailLookUpList : PageBase
    {
       
        #region 属性 (查询条件)

        /// <summary>
        /// 排序字段 值为 id
        /// </summary>
        protected override string orderField
        {
            get
            {
                return GetRequestValue<string>("orderField", "DaoQiRi");
            }
        }
        /// <summary>
        ///  排序方式 desc或 asc
        /// </summary>
        protected override string orderDirection
        {
            get
            {
                return GetRequestValue<string>("orderDirection", "ASC");
            }
        }
        protected override string SQLSort
        {
            get
            {
                return (" HeTongHao Asc,"+(orderField + " " + orderDirection) + " ");
            }
        }

        protected string JingXiaoShang
        {
            get
            {
                return GetRequestValue<string>("JingXiaoShang");

            }
        }

        protected string JiHao
        {
            get
            {
                return GetRequestValue<string>("JiHao", "");
            }
        }

        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            DataBind(); 
        }

        protected void DataBind()
        {
            this.rpMenu.DataSource = FTradeAgeDetailController.GetBalancePagination(GetSQLWhere(), pageNum, numPerPage, SQLSort, ref TotalCount);
            this.rpMenu.DataBind();
        }

        protected string GetSQLWhere()
        {
            string wheresql = "";
            string sqlcommonFiled = "";
            if (!string.IsNullOrEmpty(JingXiaoShang))
            {
                //多经销商处理
                switch (JingXiaoShang.Trim())
                {
                    case "湖南金力源":
                        sqlcommonFiled = " JingXiaoShang in('湖南金力源','湖南金土地')";
                        break;
                    case "湖南金土地":
                        sqlcommonFiled = " JingXiaoShang in('湖南金力源','湖南金土地')";
                        break;
                    case "青岛金吉宇":
                        sqlcommonFiled = " JingXiaoShang in('青岛金吉宇','青岛吉宇')";
                        break;
                    case "青岛吉宇":
                        sqlcommonFiled = " JingXiaoShang in('青岛金吉宇','青岛吉宇')";
                        break;
                    default:
                        sqlcommonFiled = QueryOperatorsEnumHelper.ConvertCommonOperator("JingXiaoShang", QueryOperatorsEnum.等于, JingXiaoShang);
                        break;
                }

               
                wheresql = sqlcommonFiled;
            }



            if (!string.IsNullOrEmpty(JiHao))
            {
                string DOWNSQL = QueryOperatorsEnumHelper.ConvertCommonOperator("JiHao", QueryOperatorsEnum.包含, JiHao);
                if (!string.IsNullOrEmpty(wheresql))
                {
                    wheresql += " and " + DOWNSQL;
                }
                else
                {
                    wheresql = DOWNSQL;
                }
            }


           

            return wheresql;
        }


        protected override string DWZRef
        {
            get { return ""; }
        }
    }
}